package com.cskaoyan.javase.string._3exercise;

/**
 * @description: 小练习
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

public class Demo {
    public static void main(String[] args) {
        String s1 = "Hello";
        String s2 = "Hello";
        String s3 = "Hel" + "lo"; //和"hello"是一个概念
        String s4 = "Hel" + new String("lo"); //一旦在堆上创建对象,做字符串拼接,都会在堆上创建新的对象
        String s5 = new String("Hello");
        String s7 = "H";
        String s8 = "ello";
        String s9 = s7 + s8; //要在堆上创建新对象

        System.out.println(s1 == s2);  //true
        System.out.println(s1 == s3);  //true
        System.out.println(s1 == s4); //false
        System.out.println(s1 == s9); //false
        System.out.println(s4 == s5); //false



    }
}
